package com.zdxlz.mongodbDemo.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import org.springframework.data.mongodb.core.mapping.FieldType;
import org.springframework.data.mongodb.core.mapping.MongoId;

@Data
@Document
@NoArgsConstructor
@Accessors(chain = true)
@AllArgsConstructor
public class Comment {
    /**
     * 主键_id
     */
    private String id;
    /**
     * 用户ID
     */
    //添加了一个单字段的索引
    @Indexed
    private String userId;
    /**
     * 评论
     */
    //该属性对应mongodb的字段的名字，如果一致，则无需该注解
    @Field("remark")
    private String comment;
}
